#include <stdio.h>
int main()
{
    int n,m,i,a[100],k,t;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    m=m%n;
    k=0;
    for(i=0;i<n;i++){
        if(m>=n-i){
     t=a[0+m-(n-i)];a[0+m-(n-i)]=a[k];a[k]=t;k=i+1; 
        }else{
            t=a[i+m];a[i+m]=a[k];a[k]=t;k=i+1;
        }
    }
    for(i=0;i<n;i++){
        if(i==0){
            printf("%d",a[i]);
        }else{
            printf(" %d",a[i]);
        }
    }
 return 0;   
}
